import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useSidebarStore = defineStore('sidebar', () => {
  const isOpen = ref(false)

  const toggleSidebar = () => {
    isOpen.value = !isOpen.value
  }

  const openSidebar = () => {
    isOpen.value = true
  }

  const closeSidebar = () => {
    isOpen.value = false
  }

  // 响应式处理
  const handleResize = () => {
    if (window.innerWidth >= 1024) {
      isOpen.value = false
    }
  }

  return {
    isOpen,
    toggleSidebar,
    openSidebar,
    closeSidebar,
    handleResize
  }
})

